//
// Created by Lenovo on 2025/8/22.
//

#ifndef CPPDEMO_PLTHOOK_H
#define CPPDEMO_PLTHOOK_H

#include <cstdio>
#include <string>

class PLTHook {
private:
    const char *TAG = "PLTHook";
    uintptr_t originFuncPtr = 0;
    uintptr_t newFuncPtr = 0;

    void printDynSymName(uintptr_t pStrTbl, uint64_t strTblSize);

public:
    uintptr_t getOriginFuncPtr();

    void setNewFuncPtr(uintptr_t newFuncPtr);

    intptr_t parseSOBaseAddress(std::string soName);

    std::pair<uintptr_t, uint64_t> getDynAddress(uintptr_t soBaseAddress);

    uintptr_t parseRELPLT(uintptr_t soBaseAddress, std::pair<uintptr_t, uint64_t> dynAddress);
};

#endif //CPPDEMO_PLTHOOK_H
